#ifndef __UTILS_CPP__
#define __UTILS_CPP__

#include <iostream>
#include <fstream>
#include <string>

using std::string;

inline bool isEscape(char ch){
    return (ch == 'b') || (ch == 't') || (ch == 'n') || (ch == 'f') || (ch == 'r') || (ch == '\"') || (ch == '\\');
}

inline string toEscape(char ch){
    switch(ch){
        case 'b':
            return "\b";
        case 't':
            return "\t";
        case 'n':
            return "\n";
        case 'f':
            return "\f";
        case 'r':
            return "\r";
        case '\"':
            return "\"";
        case '\\':
            return "\\";
    }
    return "Invalid char "; // shall never reach
}

inline bool isOneWordOperator(char ch){
    string ops = "{};[]*+-/~%&^|,";
    return ops.find(ch) != string::npos;
}

template <typename Enumeration>
inline auto enum2Int(Enumeration const value) -> typename std::underlying_type<Enumeration>::type {
    return static_cast<typename std::underlying_type<Enumeration>::type>(value);
}


#endif